{% extends 'base.html' %}
{% block title %}
    <a class="navbar-brand" href="#"> {{ department.departmentname }} 部门的员工加班记录 </a>
{% endblock %}
{% block write %}

{% endblock %}
{% block content %}
    <div class="content">
		{% if sign_in_s == [] %}
			<h4 class="title">{{ department.departmentname }}部门暂无加班记录</h4>
		{% else %}
			<h4 class="title">{{ department.departmentname }}部门的员工加班记录</h4>
		{% endif %}

        <div class="toolbar">

            <!--        Here you can write extra buttons/actions for the toolbar              -->
            <form method="post">
                    <div class="col-sm-6" style="width: auto;">
                        选择统计开始日期<input type="date" name="begin_date"  autocomplete="off" required>
                    </div>
                    <div class="col-sm-6" style="width: auto">
                    选择统计结束日期<input type="date" name="end_date"  autocomplete="off" required>
                    </div>
                    <div >
                    <input type="submit" name="submit" value="查询">
                    </div>
            </form>
        </div>
    <div class="card-footer text-center" style="margin-top: 10px">
        <input type="button" name="submit" class="btn_overtime btn" value="导出">
    </div>
    <div class="sign_in material-datatables">
        <table id="sign_in datatables" class="table table-striped table-no-bordered table-hover"
               style="width:100%;cellspacing:0">
            <thead>
            <tr>
                <th>姓名</th>
                <th>打卡日期</th>
                <th>是否加班</th>
                <th>加班时间</th>
            </tr>
            </thead>

            <tbody>
            {% for staff1 in staff %}
            {% for overtime in overtimes %}

                {% if staff1.userID == overtime.userID %}
                    <tr>
                    <td>{{ staff1.username }}</td>
                    <td>{{ overtime.overtime_date }}</td>
                    {% if overtime.overtime_hour == -1 %}
                        <td>未打卡</td>
                        <td>-1</td>
                    {% elif overtime.overtime_hour == 0 %}
                        <td>下班</td>
                        <td>0</td>
                    {% else %}
                        <td  style="color: red">加班</td>
                        <td>{{ overtime.overtime_hour }}</td>
                    {% endif %}
                    </tr>
                {% endif %}

            {% endfor %}
            {% endfor %}
            </tbody>

        </table>
    </div>
</div>
    <script type="text/javascript">
            $(function() {
                $(".btn_overtime").click(function(){
                    $(".sign_in").table2excel({
                        // 不被导出的表格行的CSS class类
                        exclude: ".noExl",
                        // 导出的Excel文档的名称
                        name: "Excel Document Name",
                        // Excel文件的名称
                        filename: "{{ staff.username }}打卡记录",
                        //文件后缀名
                        fileext: ".xls",
                        //是否排除导出图片
                        exclude_img: true,
                        //是否排除导出超链接
                        exclude_links: true,
                        //是否排除导出输入框中的内容
                        exclude_inputs: false
                    });
                });
            });
    </script>
{% endblock %}